package com.qf.vue2.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.vue2.mapper.StudentMapper;
import com.qf.vue2.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {

    @Autowired
    private StudentMapper studentMapper;

    public PageInfo<Student> findPage(int pageNum, int pageSize){

        PageHelper.startPage(pageNum,pageSize);

        List<Student> students = studentMapper.findAll();

        return new PageInfo<>(students);
    }

    public int update(Student student) {
        return studentMapper.updateByNumber(student);
    }

    public int add(Student student) {
        return studentMapper.insert(student);
    }

    public int del(String number) {
        return studentMapper.deleteByNumber(number);
    }
}
